IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fncGetCodeSuji1]') 
											AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[fncGetCodeSuji1]

GO


CREATE Function [dbo].[fncGetCodeSuji1]
(
    @CD_SYU char(5),
    @CD varchar(8)
)
RETURNS int
AS
BEGIN
	RETURN (SELECT cast(ISNULL(CD_SUJI1,0) as int) AS SUJI1 from M_CD WHERE CD_SYU = @CD_SYU AND CD_KB = '2' AND CD = @CD)
END


